<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragment::head(~{::title})">
    <meta charset="UTF-8">
    <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>发布博客</title>
    <link href="../../static/css/semantic.min.css" rel="stylesheet">
    <link href="../../static/css/style.css" rel="stylesheet">
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.css" />
</head>
<body>
<!--导航 -->
<nav th:replace="admin/_fragment::menu(1)"  class="ui inverted attached segment m-padding-tb-mini m-shadow-small">
    <div class="ui container">
        <div class="ui inverted secondary stackable menu">
            <h2 class="ui teal header item">管理后台</h2>
            <a href="#" class="m-item item m-mobile-hide"><i class="home mini icon"></i>博客</a>
            <a href="#" class="m-item item m-mobile-hide"><i class="idea mini icon "></i>分类</a>
            <a href="#" class="m-item item m-mobile-hide"><i class="tags mini icon"></i>标签</a>
            <div class="right m-item item m-mobile-hide">
               <div class="ui dropdown item">
                   <div class="text">
                       <img src="../../static/images/girl.jpeg" alt="" class="ui avatar image">
                       彭阳宴
                   </div>
                   <i class="dropdown icon"></i>
                   <div class="menu">
                       <a href="#" class="item">注销</a>
                   </div>
               </div>
            </div>
        </div>
    </div>
    <div class="ui menu toggle black icon button m-right-top m-mobile-show">
        <i class="sidebar icon"></i>
    </div>
</nav>
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">
            <a href="#" class="item teal active">发布</a>
            <a href="#" class="item">列表</a>
        </div>
    </div>
</div>

<!-- 中间内容 -->
<div class="m-padding-tb-small m-container-height">
    <div class="ui container">
        <form id="blog-form" action="#" method="post" th:object="${blog}" th:action="@{/admin/blogs/post}" class="ui form">
            <input type="hidden" name="published">
            <div class="required field">
                <div class="ui left labeled input" style="z-index: 99!important;">
                    <div class="ui selection compact teal basic dropdown label">
                        <input type="hidden" value="原创" name="flag">
                        <i class="dropdown icon"></i>
                        <div class="text">原创</div>
                        <div class="menu">
                            <div class="item" data-value="原创">原创</div>
                            <div class="item" data-value="转载">转载</div>
                            <div class="item" data-value="翻译">翻译</div>
                        </div>
                    </div>
                    <input type="text" name="title" placeholder="标题">
                </div>
            </div>
            <div id="test-editormd" class="field" style="z-index: 100!important;">
                 <textarea style="display:none;" name="content">- 请输入</textarea>
            </div>
            <div class="two fields">
                <div class="field required">
                    <div class="ui left labeled action input">
                        <label class="ui compact teal basic label">分类</label>
                        <div class="ui fluid selection dropdown">
                            <input type="hidden" name="type.id">
                            <i class="dropdown icon"></i>
                            <div class="default text">分类</div>
                            <div class="menu">
                                <div class="item" th:each="type:${types}" th:data-value="${type.id}" th:text="${type.name}">错误日志</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="field">
                    <div class="ui left labeled action input">
                        <label class="ui compact teal basic label">标签</label>
                        <div class="ui fluid multiple selection dropdown">
                            <input type="hidden" name="tagIds">
                            <i class="dropdown icon"></i>
                            <div class="default text">标签</div>
                            <div class="menu">
                                <div class="item" th:each="tag:${tags}" th:data-value="${tag.id}" th:text="${tag.name}">错误日志</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="field required">
                <div class="ui left labeled action input">
                    <label class="ui compact teal basic label">首图地址</label>
                    <input type="text" name="firstPicture" placeholder="首图地址">
                </div>
            </div>
            <div class="inline fields">
                <div class="ui checkbox">
                    <input type="checkbox" id="recommend" name="recommend" checked class="hidden">
                    <label for="recommend">推荐</label>
                </div>
                <div class="ui checkbox m-margin-left-small">
                    <input type="checkbox" id="shareInfo" name="shareable" class="hidden">
                    <label for="shareInfo">转载声明</label>
                </div>
                <div class="ui checkbox m-margin-left-small">
                    <input type="checkbox" id="money" name="appreciation" class="hidden">
                    <label for="money">赞赏</label>
                </div>
                <div class="ui checkbox m-margin-left-small">
                    <input type="checkbox" id="comments" name="commentable" class="hidden">
                    <label for="comments">评论</label>
                </div>
            </div>
            <div class="ui error message"></div>

            <div class="ui right aligned container">
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button id="save-btn"  class="ui secondary button" >保存</button>
                <button id="published-btn" class="ui teal button" >发布</button>
            </div>

        </form>
    </div>
</div>

<!-- 底部footer -->
<footer th:replace="admin/_fragment::footer"  class="ui inverted vertical segment m-margin-top-small">
    <div class="ui center aligned container">
        <div class="ui stackable inverted divided grid m-padding-tb-big">
            <div class="three wide column">
                <div class="ui item">
                    <img src="../../static/images/girl.jpeg" alt="" class="ui rounded image m-inline-block" style="width: 100px;">
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">用户故事{ user story }</a>
                    <a href="#" class="item">用户故事{ user story }</a>
                    <a href="#" class="item">用户故事{ user story }</a>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">用户故事{ user story }</a>
                    <a href="#" class="item">用户故事{ user story }</a>
                    <a href="#" class="item">用户故事{ user story }</a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mini">xxxxxxxxxxxxxxxxxxxxxxx</p>
            </div>
        </div>
        <div class="ui inverted selection divider"></div>
        <p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright © 2020 - 2021 Mr.Peng</p>
    </div>
</footer>

<!--/*/<th:block th:replace="admin/_fragment::script">/*/-->
<script src="../../static/js/jquery.min.js"></script>
<script src="../../static/js/semantic.min.js"></script>
<script src="../../static/lib/editormd/editormd.min.js"></script>
<!--/*/</th:block>/*/-->
<script>
    var testEditor;
    $(function() {
        testEditor = editormd("test-editormd", {
            width: "100%",
            height: 640,
            syncScrolling: "single",
            path: "/lib/editormd/lib/",
            emoji: true,
            tocm : true, // Using [TOCM]
            tex : true, // 开启科学公式TeX语言支持，默认关闭
            flowChart : true, // 开启流程图支持，默认关闭
            imageUpload: true,
            imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
            imageUploadURL: "/admin/file/blog/upFile"
        });
    })
</script>
<script>

    $('.menu.toggle').click(function () {
      $('.m-item').toggleClass('m-mobile-hide')
    });
    $('.ui.dropdown').dropdown({
      on: 'hover'
    });
    $('.ui.form').form({
      fields: {
        title: {
          identifier: 'title',
          rules:[{
            type: 'empty',
            prompt: '标题不能为空'
          }]
        },
          content: {
              identifier: 'content',
              rules:[{
                  type: 'empty',
                  prompt: '博客内容不能为空'
              }]
          },
          typeId: {
              identifier: 'typeId',
              rules:[{
                  type: 'empty',
                  prompt: '类型不能为空'
              }]
          }
      }
    });

    $('#save-btn').click(function () {
        $("[name='published']").val(false);
        $("#blog-form").submit();
    });

    $('#published-btn').click(function () {
        $("[name='published']").val(true);
        $("#blog-form").submit();
     })
</script>
</body>
</html>